<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<style type="text/css">	
			#box1{
				width: 200px;
				height:200px;
				background-color: red;
				
				position:absolute;
			}
		</style>	
		<script type="text/javascript">		
			
			window.onload=function(){

				//获取div节点
				var box1=document.getElementById("box1");
						
				//给document绑定事件
				document.onmousemove=function(move){
		
					
					var left=move.pageX;
					var top=move.pageY;
				
					//console.log(left+","+top);
					
					//设置div的偏移量
					box1.style.left=left+"px";
					box1.style.top=top+"px";			
				};
			};
		</script>
	</head>
	<body style="height: 1000px;">
		<div id="box1">
			
		</div>
	</body>
</html>
